package com.dudy.common.util;

import com.dudy.common.base.CommonResponse;
import com.dudy.common.base.ResultCode;

/**
 * @program: common
 * @author: dudy
 * @create: 2020-11-03 11:10
 * @description: 返回值工具类
 **/
public class ResponseUtils<T> {
    public static <T> CommonResponse<T> getResponse(ResultCode resultCode, T object) {
        return new CommonResponse<>(resultCode.getCode(), resultCode.getMassage(), object);
    }

    public static <T> CommonResponse<T> getResponse(ResultCode resultCode) {
        return getResponse(resultCode, null);
    }

    public static <T> CommonResponse<T> getResponse(int code, String message, T object) {
        return new CommonResponse<T>(code, message, object);
    }

    public static <T> CommonResponse<T> getResponse(int code, String message) {
        return getResponse(code, message, null);
    }

    public static <T> CommonResponse<T> getResponse(int code) {
        return getResponse(code, null, null);
    }

    public static <T> CommonResponse<T> getResponse() {
        return getResponse(ResultCode.FAIL);
    }

    public static <T> CommonResponse<T> getResponse(T object) {
        return getResponse(ResultCode.SUCCESS, object);
    }


}

